package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.model.equipment.EquipmentEditItem;
import com.jinmdz.fmis.dao.admin.model.equipment.EquipmentListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 冷藏柜维护Dao
 *
 * @author LiCongLu
 * @date 2020-03-10 16:41
 */
public interface EquipmentDao {
    /**
     * 查询冷藏柜列表
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-03-11 10:59
     */
    @Select(" select id,equipment_type_code,equipment_code,equipment_describe,equipment_state,column_no,row_no,disable_state,sort,remark,version " +
            "  from cold_storage_equipment where deleted = 0 order by equipment_type_code,equipment_code")
    ArrayList<EquipmentListItem> listEquipmentList();

    /**
     * 按照主键获取冷藏柜信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-03-11 10:59
     */
    @Select(" select id,equipment_type_code,equipment_code,equipment_describe,equipment_state,column_no,row_no,disable_state,sort,remark,version " +
            "  from cold_storage_equipment where id = #{id} and deleted = 0 limit 1")
    EquipmentEditItem getEquipmentEditById(@Param("id") Integer id);

    /**
     * 按照冷藏柜编码查询非当前冷藏柜信息主键
     *
     * @param equipmentId   当前冷藏柜主键
     * @param equipmentCode 冷藏柜编码
     * @return
     * @author LiCongLu
     * @date 2020-03-11 11:00
     */
    @Select(" select id from cold_storage_equipment where id != IFNULL(#{equipmentId},0) and equipment_code = #{equipmentCode} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getEquipmentIdByEquipmentCode(@Param("equipmentId") Integer equipmentId, @Param("equipmentCode") String equipmentCode);
}
